/**
 * @Author: Sagan
 * @Date: 2020/09/19 17:11
 */
package module

import (
	"gitee.com/big_meteor/godash/arr"
	"gitee.com/big_meteor/godash/lang"
	"gitee.com/big_meteor/godash/validate/constant"
	"reflect"
)

// 是否在某个范围
// 支持的类型：string
func In(v interface{}, array []string) (bool, error) {
	if 1 > len(array) {
		return false, nil
	}

	var rt reflect.Kind
	v, rt = lang.GetValue(v)

	if reflect.String != rt {
		return false, constant.ERROR_IN_UDT
	}

	flag, _ := arr.IndexOf(array, v.(string))

	return flag, nil
}
